import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
const { resolve } = require("path")
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
export default defineConfig({
  resolve: {
    alias: {
      "@": resolve(__dirname, "src"),
      "components": resolve(__dirname, "src/components"),
      "styles": resolve(__dirname, "src/styles"),
      "plugins": resolve(__dirname, "src/plugins"),
      "views": resolve(__dirname, "src/views"),
      "layouts": resolve(__dirname, "src/layouts"),
      "utils": resolve(__dirname, "src/utils"),
      "apis": resolve(__dirname, "src/apis"),
      "dirs": resolve(__dirname, "src/directives"),
    },
  },
  plugins: [
    // ...
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    , vue()],
  server: {
    proxy: {
      '/api': {
        target: 'http://39.98.123.211',
        // rewrite: path => path.replace(/^\/api/, ''), // 重写传过来的path路径，比如 `/api/index/1?id=10&name=zs`（注意:path路径最前面有斜杠（/），因此，正则匹配的时候不要忘了是斜杠（/）开头的；选项的 key 也是斜杠（/）开头的）
        changeOrigin: true,
      }
    }
  }
})
